﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using IBS.Bll;
using IBS.Model;
using IBS.ServiceContracts;

namespace BankApp.Controllers
{
    [Authorize(Roles = "Operator")]
    public class CardController : Controller
    {
        private ICardService cardService;
        private IKnowledgeBaseService knowledgeBaseService;

        public CardController()
        {
            var container = new IbsContainer();
            this.cardService = container.CardService;
            this.knowledgeBaseService =container.KnowledgeBaseService;
        }

        //
        // GET: /Card/
        public ActionResult CreateNew(int id, CardType cardType)
        {
            var client = knowledgeBaseService.GetClientById(id);
            var card = cardService.CreateNewCard(client, cardType, User.Identity.Name);
            return View();
        }
        public RedirectResult Delete(string cardNumber, string redirect)
        {
            cardService.DeleteCard(cardNumber);
            return Redirect(redirect);
        }
        public ActionResult Index()
        {
            return View();
        }

    }
}
